import users from '../../apis/users';

export default {
  namespaced: true,
  state: {
    loading: false,
    users: [],
    count: 0,
  },
  mutations: {
    setLoading(state, data) {
      state.loading = data;
    },
    setUsers(state, data) {
      state.users = data;
    },
    setCount(state, data) {
      state.count = data;
    },
  },
  actions: {
    async getUsers({ commit }, data) {
      commit('setLoading', true);
      const { data: { result, count } } = await users.getUsers(data);
      commit('setUsers', result);
      commit('setCount', count);
      commit('setLoading', false);
    },
  },
};
